<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button class="btn">提交数据</button>

    <script>
        document.querySelector('.btn').addEventListener('click', () => {
            const xhr = new XMLHttpRequest()
            xhr.open('POST', 'http://hmajax.itheima.net/api/register')
            xhr.addEventListener('loadend', () => {
                console.log(xhr.response);
            })
        })
    </script>
</body>
</html>